﻿@using NB.MGJ.Model;
@{
    Layout = null;
    AntiFleeing_IOWarehouse Warehouse = ViewBag.warehouse as AntiFleeing_IOWarehouse;
}
@*编辑入库信息*@
<script src="~/Scripts/MGJJS/FleeGoods/CommonBox.js"></script>
<style>
    .form-horizontal .form-group {
        margin-bottom: 15px;
    }
</style>
<form class="form-horizontal" id="form_EditStorage" role="form" onkeydown="if(event.keyCode==13){return false;}">

    <div class="form-group ProductName">
        <label class="col-sm-2 control-label">产品名称：</label>
        <div class="col-sm-10">
            <input type="text" class="form-control" placeholder="产品名称" name="ProductName" value="@Warehouse.ProductName" disabled="disabled">
        </div>
    </div>
    <div class="form-group ProductName">
        <label class="col-sm-2 control-label">产品名称：</label>
        <div class="col-sm-10">
            @Html.DropDownList("ProductID", null, new { @class = "form-control", @onchange = "OnChange()" })
        </div>
    </div>
    <div class="form-group">
        <label class="col-sm-2 control-label">仓库名称：</label>
        <div class="col-sm-10">
            @Html.DropDownList("WarehouseId", null, new { @class = "form-control", @onchange = "OnChange()" })
        </div>
    </div>
    <div class="form-group">
        <label class="col-sm-2 control-label">入库数量：</label>
        <div class="col-sm-10">
            <input type="text" class="form-control" placeholder="装箱数量" name="Num" value="@Warehouse.Num" disabled="disabled">
        </div>
    </div>

    <div class="form-group" style="display:flex;align-items:center">
        <label class="col-sm-2 control-label">查看物流码：</label>
        <div class="col-sm-10">
            <a href="#" onclick="$.MGJ.CommonBox.Dialog_CommonBox('@Warehouse.FilePath')">查看物流码</a>
        </div>
    </div>
    
    <div class="form-group">
        <label class="col-sm-2 control-label">货品仓位：</label>
        <div class="col-sm-10">
            <input type="text" class="form-control" placeholder="货品仓位" name="Location" value="@Warehouse.Location">
        </div>
    </div>

    <div class="form-group">

        <label class="col-sm-2 control-label">备注：</label>
        <div class="col-sm-10">
            <input type="text" class="form-control" placeholder="备注" name="Remark" value="@Warehouse.Remark">
        </div>
    </div>

    <div class="form-group">
        <label class="col-sm-2 control-label">入库编码：</label>
        <div class="col-sm-10">
            <input type="text" class="form-control" placeholder="入库编码" name="FormCode" id="FormCode" value="@Warehouse.FormCode" readonly>
            <div style="color:red">入库编码：产品编码-仓库编码-当前时间</div>
             <input type="hidden" value="@Warehouse.Id" name="ID">
        </div>
    </div>

</form>
<script>

    if ($(".ProductName").eq(0).find("input").val() == "") {
        $(".ProductName").eq(0).hide()
    } else {
        $(".ProductName").eq(1).hide()
    }
    $('#form_EditStorage').bootstrapValidator({
        fields: {
            Num: {
                validators: {
                    notEmpty: {
                        message: '入库数量不能为空'
                    },
                }
            },
            WarehouseId: {
                validators: {
                    notEmpty: {
                        message: '仓库名称不能为空'
                    },
                }
            },
            ProductID: {
                validators: {
                    notEmpty: {
                        message: '产品名称不能为空'
                    },
                }
            },
        }
    });
    OnChange();
    function OnChange() {
        var formCode = $("#FormCode").val();
        if (!formCode) {
            var proId=@Warehouse.ProductID;
            if (proId == 0) {
                proId = $("#ProductID").val();
            }
            var WarehouseId = $("#WarehouseId").val();
            $.MGJ.CommonBox.FromCode(proId+'-'+WarehouseId)
        }
    }
</script>
